草庐IT

Android JsonArray 和 JsonObject 反序列化

全部标签

c# - 反序列化 xml,包括命名空间

我正在尝试反序列化一些XML,但我无法让命名空间/xsi:type="Model"工作。如果xsi:type="Model"被排除在XML之外,它仍然有效,但它必须存在。如果我将命名空间留在我的模型之外,我会得到一个错误,如果我重命名它,我会得到一个空列表。XML238614402238614805型号[XmlRootAttribute("Vehicles")]publicclassVehicles{publicVehicles(){Vehicle=newList();}[XmlElement(ElementName="Vehicle",Namespace="http://www.w3

c# - XML 序列化 - XmlCDataSection 作为 Serialization.XmlText

我在使用c#序列化cdata部分时遇到问题我需要将XmlCDataSection对象属性序列化为元素的内部文本。我要找的结果是这样的:helloworld]]>为了产生这个,我正在使用这个对象:publicclassTest{[System.Xml.Serialization.XmlText()]publicXmlCDataSectionvalue{get;set;}[System.Xml.Serialization.XmlAttributeAttribute()]publicstringvalue2{get;set;}}在value属性上使用xmltext注释时,会抛出以下错误。Sy

json - Xml 序列化 JAXB vs Jackson-dataformat-xml?

我有一个XSD,我希望从中支持JSON和XML数据格式的序列化/反序列化。我使用xjc工具生成了我的模型类。到目前为止,我已经使用JacksonJSON库处理了JSON数据。我不能修改我的Java类,所以我配置了ObjectMapperMix-Inannotations和其他功能,如PropertyNamingStrategy(更改字段名称),SerializationFeature.WRAP_ROOT_VALUE通过代码为我的序列化提供配置。现在我想对XML序列化过程做同样的事情。我已经在线阅读了各种选项:JAXBJackson库+Jackson-dataformat-xml.jar

c# - 如何在不包装元素的情况下对多态数组进行 XML 序列化

想要将我的数据序列化为:但我得到的是这个(注意包装的Commands元素)这是用于生成此代码的示例代码:publicclassBaseCommand//baseclass{[XmlAttribute]publicstringResult{get;set;}}publicclassExecuteCommand:BaseCommand{[XmlAttribute]publicstringCommand{get;set;}}publicclassWaitCommand:BaseCommand{[XmlAttribute]publicintSeconds{get;set;}}publiccla

c# - 如何反序列化为动态类型

我正在尝试反序列化我的XML以获得动态创建的类型数组(使用codedom),然后我使用反射加载该程序集并加载动态创建的类型。当我尝试反序列化我的XML(它有一个动态生成类型的对象集合)时,我不确定如何向序列化程序提供该类型。我的代码示例:Assemblyassembly=Assembly.LoadFile("myDynamicassembly.dll");Typetype=assembly.GetType("myDynamicType");stringxmlstring=myXml.OuterXml.ToString();byte[]buffer=ASCIIEncoding.UTF8.

.net - XML 序列化,无空格

我有以下序列化方法:PrivateFunctionSerializeData(ByValdataAscData)AsStringIfdataIsNotNothingThenDimxml_streamAsNewMemoryStream()DimsrAsStreamReaderDimxsAsNewXmlSerializer(GetType(cData))xml_stream=NewMemoryStream()Tryxs.Serialize(xml_stream,data)xml_stream.Position=0sr=NewStreamReader(xml_stream)Returnsr.

c# - C# 中的 XML 序列化数组

我无法解决这个问题,我有一个看起来像这样的xml表TEST1TEST2TEST3TEST4TEST5TEST6TEST1TEST2TEST3TEST4TEST5TEST6我正在尝试将其序列化为publicclassItems{[XmlAttribute("id")]publicstringID{get;set;}[XmlAttribute("title")]publicstringTitle{get;set;}//Idon'tknowwhattodoforthis[Xml...something]publiclistWords{get;set;}}//Idon'tthisthisisr

C# 序列化对象版本

我有以下情况。在我的C#应用程序中,我有一个使用XmlSerializer序列化的类。该类非常复杂,我类的一个对象作为应用程序文件保存在本地磁盘上,稍后可以打开(经典的保存工作和重新打开工作)。我的问题是在开发过程中,被序列化的对象的类可能会改变。我想要一个版本系统,它允许我的应用程序意识到保存的xml属于旧版本但仍然可以打开。旧的应用程序版本也无法打开新的xml版本。例如:classComplexObject{publicstringsettings1;publicstringsettings2;}我序列化对象,在生产中发送应用程序。明天我的课变成了classComplexObjec

c# - XML 字符串数组反序列化为不同的类型名称

我有以下C#类属性:privateList_accountTypes;[XmlArray(ElementName="accountTypes")]publicListAccountTypes{get{return_accountTypes;}set{_accountTypes=value;}}在类构造函数中是这样初始化的:_accountTypes=newList(newstring[]{"OHGEE","OHMY","GOLLY","GOLLYGEE"});当反序列化时我得到这个:OHGEEOHMYGOLLYGOLLYGEE如果我能得到这个我会喜欢的:OHGEEOHMYGOLLYGO

xml - 为什么 Apache Xerces/Xalan 向我的序列化输出添加额外的回车符?

我使用的是ApacheXerces2.11.0和ApacheXalan2.7.1,我在序列化XML中遇到额外的回车符问题。我有这个(伪)代码:StringmyString=...;Documentdoc=...;Elementitem=doc.createElement("item");item.appendChild(doc.createCDATASection(myString));Transformertransformer=...;ByteArrayOutputStreamstream=newByteArrayOutputStream();Resultresult=newStr